# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=astroid
pkgbase=mingw-w64-python2-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}")
pkgver=1.6.5
pkgrel=2
pkgdesc="Useful miscellaneous modules used by Logilab projects (mingw-w64)"
arch=('any')
url="https://github.com/PyCQA/astroid"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-python2-six"
         "${MINGW_PACKAGE_PREFIX}-python2-lazy-object-proxy"
         "${MINGW_PACKAGE_PREFIX}-python2-wrapt"
         "${MINGW_PACKAGE_PREFIX}-python2-singledispatch"
         "${MINGW_PACKAGE_PREFIX}-python2-enum34"
         "${MINGW_PACKAGE_PREFIX}-python2-backports.functools_lru_cache")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python2-dateutil"
              "${MINGW_PACKAGE_PREFIX}-python2-pytest"
              "${MINGW_PACKAGE_PREFIX}-python2-numpy"
              "${MINGW_PACKAGE_PREFIX}-python2-nose")
source=(https://github.com/PyCQA/astroid/archive/astroid-$pkgver.tar.gz)
sha512sums=('b08a178db78114cdaa02283dacd9aab63c3e2e0586d003d83de13ee362c539d36a9547d57baa561de475e168690e997de49210c122848ec60ffef943b9eaabc7')

prepare() {
  cd "${srcdir}"
   rm -rf "python2-build-${CARCH}" | true
   cp -r "${_realname}-${_realname}-${pkgver}" "python2-build-${CARCH}"
  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
}

build() {
  msg "Python 2 build for ${CARCH}"  
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

check() {
  msg "Python 2 test for ${CARCH}"
  cd "${srcdir}/python2-build-${CARCH}"
  ${MINGW_PREFIX}/bin/pytest2 || warning "Tests failed"
}

package() {
  cd "${srcdir}/python2-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

}
